<?php
/**
 * Created by PhpStorm.
 * User: 沁芳阁
 * Date: 2016/12/23
 * Time: 15:36
 */

namespace service\services;


use service\entity\AlgoLog;
use service\entity\UserAlgoRequestLog;
use service\entity\UserAlgoTagCodeLog;

class AlgoLogService extends CommonService
{

    function getRequestLogList($map,$pageSize,$param,$isAll = false)
    {
        $model=new UserAlgoRequestLog();
        if ($isAll) {
            $page="";
            $result=$model->where($map)->order("id desc")->select();
        } else {
            $result = $model->where($map)->order("id desc")->fetchSql(false)->paginate($pageSize, false, array('query' => $param));
            $page = $result->render();
        }
        return ["data" => $result, "page" => $page];
    }

    function getTagCodeLogList($map,$pageSize,$param,$isAll = false)
    {
        $model=new UserAlgoTagCodeLog();
        if ($isAll) {
            $page="";
            $result=$model->where($map)->order("id desc")->select();
        } else {
            $result = $model->where($map)->order("id desc")->paginate($pageSize, false, array('query' => $param));
            $page = $result->render();
        }
        return ["data" => $result, "page" => $page];
    }

    function getRequestApiList()
    {
        $model=new UserAlgoRequestLog();
        $result=$model->distinct(true)->field('request_api')->column("request_api");
        return $result;
    }


}